903B - The Modcrab - CodeForces Solution


greedy implementation *1200

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
using ll =long long;
//const ll N=1e7+1;
#define pb push_back



// TEMPLATES
 
 template <typename T> // cin >> vector<T>
istream &operator>>(istream &istream, vector<T> &v)
{
    for (auto &it : v)
        cin >> it;
    return istream;
}
 
template <typename T> // cout << vector<T>
ostream &operator<<(ostream &ostream, const vector<T> &c)
{
   for (auto &it : c)
      cout << it << " ";
   return ostream;
}



long long binconvert(int n) 
{
  long long bin = 0;
  int rem, i = 1;
 
 
  while (n!=0) {
    rem = n % 2;
    n /= 2;
    bin += rem * i;
   
    i *= 10;
  }
 
 
  return bin;
}

bool isprime(ll n)
{
    int cnt=0;
    for(int i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            cnt++;
            if(i!=n/i)
            {
                cnt++;
            }
 
        }
        
    }
    if(cnt>2)
    {
        return 0;
    }
    return 1;
}
ll fact(ll n)
{
      if(n==0)
      return 1;
    ll res = 1;
    for (int i = 2; i <= n; i++)
        res = res * i;
    return res;
}
 
ll ncr(ll n, ll r)
{
    return fact(n) / (fact(r) * fact(n - r));
}
vector<ll>m(102,0);
void solve2(ll d,vector<ll>v,ll s,ll e)
{
     if(s>=e)
     {
        return;
     }
   ll mx=INT_MIN;
   ll ind=0;
    for(int i=s;i<e;i++)
    {
        if(v[i]>mx)
        {
            mx=v[i];
            ind=i;

        }
    }
    m[v[ind]]=d;
    d++;
    solve2(d,v,s,ind);
    solve2(d,v,ind+1,e);

}
//vector<int>prime(N+2,1);
// void sieve_erastosthenes()
// {
//      for(int i=2;i*i<=N+1;i++)
//      {
//         if(prime[i]==1)
//         {
//             for(int j=i*i;j<=N+1;j+=i)
//             {
//                 prime[j]=false;
//             }
//         }
//      }


// }
void solve()
{
    int a1,a2,h1,h2,c1;
    cin>>h1>>a1>>c1;
    cin>>h2>>a2;
    int count=0;
    while(ceil(h1*1.0/a2)<ceil(1.0*h2/a1))
    {
      
        count++;
        h1+=c1-a2;
    }
    int z=ceil(h2*1.0/a1*1.0);
    cout<<count+z<<"\n";
    while(count--)
    {
          cout<<"HEAL"<<"\n";
    }
    while(z--)
    {
        cout<<"STRIKE"<<"\n";

    }

    
}
int main()
{
    ll t;
    t=1;
  // cin>>t;
  // sieve_erastosthenes();
    while(t--)
    {
        solve();
    }
}


Comments

Submit
0 Comments
More Questions

109A - Lucky Sum of Digits
864C - Bus
626B - Cards
1221A - 2048 Game
1374D - Zero Remainder Array
1567C - Carrying Conundrum
1029C - Maximal Intersection
922C - Cave Painting
811C - Vladik and Memorable Trip
1589C - Two Arrays
1510K - King's Task
126B - Password
462A - Appleman and Easy Task
839C - Journey
622A - Infinite Sequence
659C - Tanya and Toys
1266A - Competitive Programmer
234C - Weather
1332C - K-Complete Word
525C - Ilya and Sticks
1555C - Coin Rows
1324C - Frog Jumps
715A - Plus and Square Root
774D - Lie or Truth
1186D - Vus the Cossack and Numbers
505B - Mr Kitayuta's Colorful Graph
1324D - Pair of Topics
157B - Trace
34C - Page Numbers
279A - Point on Spiral